use std::sync::{Arc, Mutex};
use std::{thread, vec};
use tokio::time::{sleep, Duration};
// from_secs 秒
// from_millis 毫秒
// from_micros 微秒
// from_nanos 纳秒

// === 异步控制 ===
pub async fn create_async1() {
    println!("server 1 => ...");
    sleep(Duration::from_millis(2000)).await;
    println!("server 1 => ok");
}

pub async fn create_async2() {
    println!("server 2 => ...");
    sleep(Duration::from_millis(1000)).await;
    println!("server 2 => ok");
}

// === 多线程 ===
pub fn create_bf1() {
    // 创建一个新线程，并执行它(服务员1)
    let handle = thread::spawn(|| {
        for i in 0..10 {
            println!("server 1 => {}", i);
            thread::sleep(Duration::from_millis(300));
        }
    });

    // 主线程 (服务员2)
    for i in 0..10 {
        println!("server 2 => {}", i);
        thread::sleep(Duration::from_millis(300));
    }

    // 等待所有线程完成
    handle.join().unwrap();
    println!("await server all =>  ok");
}
